package com.cowin.webservice.monitor;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.cowin.base.result.Result;
import com.cowin.base.result.ResultGenerator;
import com.cowin.inf.model.KyDeviceState;
import com.cowin.inf.model.KyLineState;
import com.cowin.inf.service.KyDeviceStateService;
import com.cowin.inf.service.KyLineStateService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import javax.jws.WebService;

/**
 * Copyright (C), 1998-2018, 奇瑞信息
 *
 * @author : 于超
 * @Date: 2019/9/19 13:56
 * @Description:
 */
@WebService(serviceName = "monitorWebService", targetNamespace = "http://monitor.webservice.cowin.com", endpointInterface = "com.cowin.webservice.monitor.MonitorWebService")
@Component
@Slf4j
public class MonitorWebServiceImpl implements MonitorWebService {

    @Resource
    private KyLineStateService kyLineStateService;

    @Resource
    private KyDeviceStateService kyDeviceStateService;

    @Override
    public Result lineStateMonitor(String parameters) {
        log.info("产线状态=={}", parameters);
//        KyLineState kyLineState;
//        try {
//            kyLineState = JSONObject.parseObject(parameters, KyLineState.class);
//        } catch (Exception e) {
//            e.printStackTrace();
//            return ResultGenerator.genFailResult("参数格式不对");
//        }
//        return kyLineStateService.lineStateMonitor(kyLineState);
        return ResultGenerator.genSuccessResult("产线状态 接收成功");
    }

    @Override
    public Result deviceStateMonitor(String parameters) {
        log.info("设备状态=={}", parameters);
//        KyDeviceState kyDeviceState;
//        try {
//            kyDeviceState = JSONObject.parseObject(parameters, KyDeviceState.class);
//        } catch (Exception e) {
//            e.printStackTrace();
//            return ResultGenerator.genFailResult("参数格式不对 请检查"+parameters);
//        }
//        return kyDeviceStateService.deviceStateMonitor(kyDeviceState);
        return ResultGenerator.genSuccessResult("设备状态 接收成功");
    }
}
